﻿Public MustInherit Class Utils

    <Obsolete("Bitte DbNull2Nothing(Of T) verwenden.")>
    Public Overloads Shared Function DbNull2Nothing(ByVal value As Object) As Object
        If TypeOf value Is System.DBNull Then
            Return Nothing
        Else
            Return value
        End If
    End Function

    Public Overloads Shared Function DbNull2Nothing(Of T)(ByVal value As Object) As T
        If TypeOf value Is System.DBNull Then
            Return Nothing
        Else
            Return CType(value, T)
        End If
    End Function

    Public Shared Function Nothing2DbNull(ByVal value As Object) As Object
        If value Is Nothing Then
            Return System.DBNull.Value
        Else
            Return value
        End If
    End Function

    Public Shared Function Boolean2Integer(ByVal value As Boolean) As Integer
        If value Then
            Return 1
        Else
            Return 0
        End If
    End Function

    Public Shared Function Integer2Boolean(ByVal value As Integer) As Boolean
        Return (value > 0)
    End Function
End Class
